package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.hf.HfTransferRequest;
import com.trhui.mallbook.domain.request.yb.YbTransferRequest;
import com.trhui.mallbook.domain.response.hf.HfTransferResponse;
import com.trhui.mallbook.domain.response.yb.YbTransferResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * 转账接口
 *
 * @Author xgc
 * @Date 2023/08/22 18:19
 **/
public class TransferClient extends AbstractClient {
    /**
     * 汇付转账接口
     *
     * @param request 汇付转账请求对象
     * @return
     */
    public static BaseResponse<HfTransferResponse> hfTransfer(HfTransferRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.TRANSFER)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(apiRequest, HfTransferResponse.class);
    }

    /**
     * 易宝转账接口
     *
     * @param request 易宝转账请求对象
     * @return
     */
    public static BaseResponse<YbTransferResponse> ybTransfer(YbTransferRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.TRANSFER)
                .channelType(ChannelTypeEnum.YB)
                .build();
        return post(apiRequest, YbTransferResponse.class);
    }
}
